package com.deli.controller;

import com.deli.service.TestOrderService;
import com.deli.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author: xudeli
 * @CreateDate: 2019/4/22 22:47
 **/
@RestController
public class TestController {



    public TestController() {
    }

    Map<String, TestOrderService> testOrderServiceMap = new HashMap();
    @Autowired
    private TestController(List<TestOrderService> testOrderServices){
        for (TestOrderService testOrderService : testOrderServices) {
            testOrderServiceMap.put(testOrderService.Type(), testOrderService);
        }
    }

    @RequestMapping("/order")
    public String getType(@RequestParam("type") String type) {

        TestOrderService testOrderService = testOrderServiceMap.get(type);
        if (testOrderService == null) {
            return "未找到类型";
        }
        String queryType = testOrderService.queryType(type);
        System.out.println(queryType);
        return queryType;
    }


}
